<!DOCTYPE html>
<html id='root'>
<body>
<input type="text" id="inputfield" style='width:5em' value='Lengthy text goes here.' />
<script>
    function select() {
        var input = document.getElementById('inputfield');
        input.focus();
        var range = input.setSelectionRange(0, 6);
        window.getSelection().addRange(range);
    }
    window.onload = select;
</script>
</body>
</html>

